<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>开关灯</title>
	</head>
	<body onload="init()">
		<img src="../img/close.jpg"/>
		
		<script>
			function init(){
				var img = document.getElementsByTagName("img")[0];
				//添加鼠标事件
				img.onmouseover = function(){
					//修改元素对象的属性
					this.src = "../img/open.jpg";
				}
				
				img.onmouseout = function(){
					this.src = "../img/close.jpg";
				}
			}
		</script>
	</body>
</html>
